<!doctype html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>教育资源-教师资源</title>
	<link rel="stylesheet" href="css/common.css">
	<link rel="stylesheet" href="css/articleMain.css">	
</head>
<body>
<div id ="header" ></div>
<div class="aticleMainBg">
	<div class="aticleMain clearfix">
		<div class="leftBar">
			<p class="nav2">
				<a href="allSpace.html">工作空间</a>
				<span>&gt;</span>
				<a href="article.html">文章</a>
				<span>&gt;</span>
				<a>文章分类管理</a>
			</p>
			<h2 class="categoryTit">文章分类管理</h2>
			<div class="post-class" id="post-class">
				<ul class="class">
					<li class="bor3 root_title " id="class01">
						<div class="admin_normal" id="normal-3310997">
							<span class="ttt" title="分类一(55)">分类一(总)</span>	
							<a href="javascript:;" title="添加子类" rel="3310997" class="c_tx class_add_link">添加子类
							</a>
							<a href="javascript:;" title="编辑分类" rel="3310997" class="c_tx class_edit_link">编辑
							</a>
							<a href="javascript:;" title="删除分类" rel="3310997" class="c_tx class_del_link">删除
							</a>
							<span class="icon_move">拖拽</span>					
						</div>
					</li>
					<li>
						<div class="admin_normal" id="normal-3310666">
							<span class="ttt" title="分类一">分类一</span>
							<span class="num">(分)</span>
							<a href="javascript:;" title="编辑分类" rel="3310998" class="c_tx class_edit_link">编辑</a>
							<a href="javascript:;" title="删除分类" rel="3310998" class="c_tx class_del_link">删除</a>
							<span class="icon_move">拖拽</span>
						</div>
					</li>
					<li>
						<div class="admin_normal" id="normal-3310555">
							<span class="ttt" title="分类一">分类一</span>
							<span class="num">(分二)</span>
							<a href="javascript:;" title="编辑分类" rel="3310999" class="c_tx class_edit_link">编辑</a>
							<a href="javascript:;" title="删除分类" rel="3310999" class="c_tx class_del_link">删除</a>
							<span class="icon_move">拖拽</span>
						</div>
					</li>
					<li class="bgc3 new_child" id="class-3310997-new-child" style="display:none">
			            <div class="admin_edit"><span>
			                <input id="class-3310997-new-child-input" type="text" class="bor2" maxlength="16">
			                <button title="确定" type="button" class="bt_tx2 new_child_confirm_btn" rel="3310997">确定</button>
			                <button title="取消" type="button" class="bt_tx3 new_child_cancel_btn" rel="3310997">取消</button>
			                </span>
			            </div>
					</li>
					<!-- 添加主类 -->
					<li class="bgr3 new_root" id="class-new" style="display:none">
			            <div class="admin_edit"><span>
			                <input id="class-new-input" type="text" class="bor2" maxlength="16">
			                <button title="确定" type="button" class="bt_tx2 new_confirm_btn">确定</button>
			                <button title="取消" type="button" class="bt_tx3 new_cancel_btn">取消</button>
			                </span></div>
			        </li>
			        <!-- 添加主类 -->
				</ul>
			</div>
			<div class="link_addBox">
				<span class="rtbutton">
					<a href="javascript:;" title="排序管理" class="class_order gray_btn" style="font-size:12px; font-weight:normal;">排序管理</a>
					<input type="button" title="保存排序" class="class_order_edit class_order_confirm blue_smallbtn" value="保存">
					<input type="button" title="取消排序" class="class_order_edit class_order_cancel mgl5 gray_smallbtn" value="取消">
				</span>
				<a  class="oneLink" id="show-class-new">添加主类</a>
				<a href="article.html">返回文章列表</a>
			</div>
			<div class="tipText">
				<p class="titPtit">
					温馨提示
				</p>
				<p class="cont">
					 1.分类下有文章时不能删除。
					 <br/>
					 2.点击分类编辑按钮可修改文章分类名称，点击确定按钮即可生效。
					 <br/>
					 3.请您注意，分类名称长度不超过8个全角字符长度，超过自动截除。
				</p>
			</div>
		</div>
		<div class="rightdata marginTop40">
			<p class="tit">
				<span class="bigList">文章分类</span>
			</p>
			<a class="allAticle act newTopBorder">全部文章</a>
			<a href="##" class="changeLine">
				分类1
				<i class="categroyLogo"></i>
			</a>
			<div class="detailLine">
				<a class="allAticle" href="">分类1aaaaa<span class="num">2</span></a>
				<a class="allAticle" href="">分类1bbbbb<span class="num">3</span></a>
			</div>
			<a href="##" class="changeLine">
				分类2
				<i class="categroyLogo"></i>
			</a>
			<div class="detailLine">
				<a class="allAticle" href="">分类1aaaaa<span class="num">2</span></a>
				<a class="allAticle" href="">分类1bbbbb<span class="num">3</span></a>
			</div>
		</div>
	</div>
</div>
<div class="footerBot"></div>
<script src="./js/jquery2.js"></script>
<script src="./js/jquery-ui-1.10.3.custom.min.js"></script>
<script src="./js/fxtpl.plus.js"></script>
<script src="./layui/layui.all.js"></script>
<link rel="stylesheet" href="./layui/css/layui.css">
<link rel="stylesheet" href="./js/blogcategorymanage.css">
<script>
 var numSpace = {numSpace:3};
 var header = Fxtpl.render('./weight/headerAllInputChange.html',numSpace);
 $('#header').html(header);
 // select more click
 $(".frLink dt").on("click",function(){
 	var ChangeData = $(this).siblings(".ddClick");
 	if(ChangeData.css("display") == "none"){
 		ChangeData.css("display","block");
 	}else {
 		ChangeData.css("display","none");
 	}
 });
 // 点击默认的分组
 $(".rightdata .changeLine").on("click",function(){
 	var _this =$(this);
 	if(_this.hasClass("cur")){
 		_this.removeClass("cur");
 	}else {
 		_this.addClass("cur");
 	}

 	if(_this.next(".detailLine").css("display")=="none"){
 		_this.next(".detailLine").show(500);
 	}else if(_this.next(".detailLine").css("display")=="block"){
 		_this.next(".detailLine").hide(500);
 	}
 });

 /* 选择功能的制作 start*/

 $(".writeLine .linkA").on("click",function(){
 	$(".writeLine").css("display","none");
	$(".ids_manage").css("display","block");
 });

 $(".signOutManger").on("click",function(){
 	$(".writeLine").css("display","block");
	$(".ids_manage").css("display","none");
 });

 // 全选的功能
 $(".chkAll").on("click",function(){
 	if($(this).hasClass("checked")==true){
 		$(this).removeClass("checked");
 		//not all select
 		$(".inputSelect").removeClass("checked");
 	}else {
 		$(this).addClass("checked");
 		// all select
 		$(".inputSelect").addClass("checked");
 	}
 	return false;
 });

// 单个的点击之后回显点击
$(".inputSelect").on("click",function(){
	var flag=true;
	if($(this).hasClass("checked")==true){
		$(this).removeClass("checked");
	}else {
		$(this).addClass("checked");
		// show if allShow
		$(".inputSelect").each(function(){
			if(!$(this).hasClass("checked")){//有没选中的
				flag=false;
			}
		});
		if(flag){
			$('#chkAll').addClass("checked");
		}else{
			$('#chkAll').removeClass("checked");
		}
	}
	return false;
});
 /*点击到了这个里面了 end */ 
 /*左右点击实现好那个东西*/ 
 $(".titShang .tap a").on("click",function(){
 	var num=$(".titShang .tap a").index($(this));
 	$(".titShang .tap a").each(function(){
 		$(this).removeClass("on");
 	});
 	$(this).addClass("on");
 	$(".leftBar .mainAticle").each(function(){
 		$(".leftBar .mainAticle").removeClass("actOn");
 	});
 	$(".leftBar .mainAticle").eq(num).addClass("actOn");
 });

 //分类排序
 $(".class_order").live("click",function(){
 	$(".c_tx").hide();
 	$(".class_order").hide();
 	$(".class_order_edit").show();
 	$(".icon_move").show();
 	$("ul.class li").css('cursor','move');
 	$("ul.class li").mousedown(function(){
 		$("ul.class li").not(this).removeClass('drag');
 		$(this).addClass('drag');
 	});
 	$("ul.class li").mouseup(function(){
 		$("ul.class li").removeClass('drag');
 	});
 	$("ul.class").sortable({
 		axis: 'y',
 		placeholder: "bor3_highlight",
 		cancel: ".ui-state-disabled"
 	});
 	$("ul.class").disableSelection();
 });
$(".class_add_link").on("click",function(){
	var rand = Math.random()*10000;
	var id = $(this).attr("rel");
	$("#class-"+id+"-new-child").show();
});

$("#show-class-new").live("click",function(){
	$("#class-new").toggle();
});

$(".class_order_confirm").live("click",function(){
	var i = 0;
	var ids = [];
	$('.bor3').each(function(){
		ids[i] = $(this).attr("id").split('-')[1];
		console.log(ids[i]);
		i++;
	});
	var id_0_html = $("ul.class #class-"+ids[0]+" .ttt").html();
	var id_0_root = $("ul.class #class-"+ids[0]).hasClass("root_title");
	if(!id_0_root){
        var content = "分类排序错误！《"+id_0_html+"》"+"不在任何主类下，请重新调整。";
        layer.msg(content, {icon: 5});
		return false;
	}
	var ids_str = ids.join(",");
	var rand = Math.random()*10000;
	var route_categoryManage = $('#route_categoryManage').val();
	var route_categoryOrderNew = $('#route_categoryOrderNew').val();
	//ajax同步调用
});

$(".class_order_cancel").live("click",function(){
	var rand = Math.random()*10000;
	window.location.href = 'aticleManger.html?rand='+rand;
});
/*添加子类的制作*/
$(".new_child_confirm_btn").on("click",function(){
	$(this).attr('disabled','disabled');
	if($(this).siblings("input").val().length==0){
		layer.msg("分类名称不能为空", {icon: 5});	
	}else{
		/*发送请求把请求弄下来*/
		$(this).removeAttr('disabled');
	}
}); 

$(".new_child_cancel_btn").on("click",function(){
	var id = $(this).attr("rel");
	$("#class-"+id+"-new-child").hide();
}); 

// 把主类的确定和按钮添加进去
$(".new_confirm_btn").on("click",function(){
	$(this).attr('disabled','disabled');
	if($(this).siblings("input").val().length==0){
		layer.msg("分类名称不能为空", {icon: 5});	
		return false;
	}
	/*发送请求把请求弄下来*/
	layer.msg("发送请求了，请稍等", {icon: 1});
	$(this).removeAttr('disabled');
});
$(".new_cancel_btn").live("click",function(){
	$("#class-new").hide();
});
</script>
</body>	
</html>